#!/usr/bin/python3
# -*- coding:utf-8 -*-
"""
@author: 
@time: 2024/12/2 21:36
@Function: 注册校验
"""

from fastapi import APIRouter, status, HTTPException
from pydantic import BaseModel, Field
from orm.models import User_Register

api_userInfo = APIRouter()


class User_Info(BaseModel):
    username: str = Field(..., title="用户名", description="用户名", max_length=20)


@api_userInfo.post('/getUserInfo', status_code=status.HTTP_200_OK)
async def user_register():
    user_info_list = await User_Register.all()
    if user_info_list is None:
        raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED,
                            detail="用户信息不存在")
    else:
        return {
            "status": status.HTTP_200_OK,
            "message": "查询成功",
            "data": {
                "username": user_info_list
            }
        }
